package projectiles
{
	import enemies.*;
	
	/**
	 * ...
	 * @author JAC
	 */
	public class Projectile extends Unit
	{
		public function Projectile(i:uint = 0, j:uint = 0)
		{
			super(i, j);
			
			Registry.projectiles.add(this);
			
			toggleLight();
		}
		
		public function overlapWithEnemy(e:Enemy):void
		{
			// Override this function
		}
		
		override public function update():void
		{
			super.update();
			
			if (alive && notMoving)
			{
				kill();
			}
		}
		
		override public function kill():void
		{
			alive = false;
			play("DYING");
		}
		
		public function launch(launchDirection:uint):void
		{
			switch (launchDirection)
			{
				case UP: 
				{
					velocity.y = -speed;
					break;
				}
				case DOWN: 
				{
					velocity.y = speed;
					break;
				}
				case LEFT: 
				{
					velocity.x = -speed;
					break;
				}
				case RIGHT: 
				{
					velocity.x = speed;
					break;
				}
				default: 
				{
					break;
				}
			}
		}
		
		override protected function onDeath():void
		{
			Registry.projectiles.remove(this, true);
			super.onDeath();
		}
	
	}
}